<template>
  <div class="login-container">
    <transition :name="loginMode">
      <accountLogin
        v-if="loginMode == 'account'"
        :silent="silent"
        @switch="loginMode = 'phone'"
      />
      <phoneLogin
        v-else-if="loginMode == 'phone'"
        :silent="silent"
        @switch="loginMode = 'account'"
      />
    </transition>
  </div>
</template>

<script>
import accountLogin from './components/account-login.vue'
import phoneLogin from './components/phone-login.vue'
let _this = null
export default {
  name: 'Login',
  props: ['silent'],
  provide: {
    loginSuccess () {
      // 触发父组件的login方法
      _this.loginComplete()
    }
  },
  components: { accountLogin, phoneLogin },
  data () {
    return {
      loginMode: 'account'
    }
  },
  created () {
    _this = this
    sessionStorage.removeItem('tags')
  },
  methods: {
    loginComplete () {
      this.$emit('login')
    }
  }
}
</script>

<style lang="scss" scoped>
.login-container {
  height: 100%;
  width: 100%;
  min-height: 600px;
  min-width: 1200px;
  overflow: hidden;
  background: url(../../assets/login-bg.jpg) center/cover;
  perspective: 1500;
  -webkit-perspective: 1500;

  :deep(.login-form) {
    // width: 425px;
    // min-height: 455px;
    background-color: rgba(255, 255, 255, 1);
    border-radius: 10px;
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1);
    position: absolute;
    right: 15%;
    top: calc(50% - 234px);
    z-index: 1;
    padding: 50px;

    .el-form {
      display: flex;
      flex-direction: column;
      justify-content: space-between;

      .title-container {
        position: relative;
        text-align: center;
        height: 68px;
        display: flex;
        align-items: center;
        margin-bottom: 50px;
        margin-left: 16px;

        .title {
          margin-left: 15px;
          font-size: 35px;
          color: #888888;
          font-weight: 300;
        }
      }

      .el-form-item {
        border-bottom: 1px solid rgba(128, 128, 128, 0.1);
        color: #454545;
        display: flex;
        align-items: center;

        .el-form-item__content {
          flex: 1;
          // margin-right: 15px;

          .el-input {
            input {
              border: none;
              background: transparent;
              -webkit-appearance: none;
              border-radius: 0px;
              padding: 12px 5px 12px 12px;
              height: 47px;
              caret-color: #409eff;
              font-size: 18px;
            }

            .el-input-group__append {
              padding: 0;
              background-color: transparent;
              border: 1px solid transparent;
            }
            &.password-input {
              width: calc(100% - 26px);
            }
          }
        }
      }

      .login-submit {
        margin: 35px auto 0;
        background-color: #22b938;
        border-color: #22b938;
        height: 55px;
        width: 191px;
        font-size: 20px;
        border-radius: 2rem;
        z-index: 1;
      }
      .switch-login {
        text-align: right;
        span {
          font-size: 13px;
          color: #409eff;
          cursor: pointer;
          user-select: none;
        }
      }
    }
  }

  :deep(.tips) {
    font-size: 14px;
    color: #fff;
    margin-bottom: 10px;

    span {
      &:first-of-type {
        margin-right: 16px;
      }
    }
  }

  :deep(.svg-container) {
    padding: 6px 5px 6px 15px;
    color: #6b8896;
    display: inline-block;
    font-size: 28px;

    > img {
      width: 28px;
      vertical-align: top;
    }
  }

  :deep(.show-pwd) {
    position: absolute;
    right: 0px;
    top: 11px;
    font-size: 24px;
    color: #889aa4;
    cursor: pointer;
    user-select: none;
    &.eye-open {
      color: #409eff;
    }
  }

  .account-enter,
  .phone-leave-to {
    transform: rotateY(-180deg);
    opacity: 0;
  }
  .account-enter-active,
  .account-leave-active,
  .phone-enter-active,
  .phone-leave-active {
    transition: all 0.6s linear;
  }
  .account-enter-to,
  .account-leave,
  .phone-enter-to,
  .phone-leave {
    transform: rotateY(0deg);
    opacity: 1;
  }
  .account-leave-to,
  .phone-enter {
    transform: rotateY(180deg);
    opacity: 0;
  }
}
</style>
